home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / muds / mordor_2.000 / mordor_2 / src / magic6.c < prev    next >
C/C++ Source or Header  |  1995-06-21  |  8KB  |  307 lines

  1. /*
  2.  * MAGIC6.C:
  3.  *
  4.  *    Additional spell-casting routines.
  5.  *
  6.  *    Copyright (C) 1991, 1992, 1993 Brett J. Vickers
  7.  *
  8.  */
  9.  
  10. #include "mstruct.h"
  11. #include "mextern.h"
  12.  
  13. /************************************************************************/
  14. /*                resist_magic                */
  15. /************************************************************************/
  16.  
  17. /* This function allows players to cast the resist-magic spell.  It    */
  18. /* will allow the player to resist magical attacks from monsters    */
  19.  
  20. int resist_magic(ply_ptr, cmnd, how)
  21. creature    *ply_ptr;
  22. cmd        *cmnd;
  23. int        how;
  24. {
  25.     creature    *crt_ptr;
  26.     room        *rom_ptr;
  27.     int        fd;
  28.  
  29.     fd = ply_ptr->fd;
  30.     rom_ptr = ply_ptr->parent_rom;
  31.  
  32.     if(ply_ptr->mpcur < 12 && how == CAST) {
  33.         print(fd, "Not enough magic points.\n");
  34.         return(0);
  35.     }
  36.  
  37.     if(!S_ISSET(ply_ptr, SRMAGI) && how == CAST) {
  38.         print(fd, "You don't know that spell.\n");
  39.         return(0);
  40.     }
  41.     if(spell_fail(ply_ptr)) {
  42.                 if(how == CAST)
  43.                      ply_ptr->mpcur -= 12;
  44.                 return(0);
  45.         }
  46.  
  47.     if(cmnd->num == 2) {
  48.         ply_ptr->lasttime[LT_RMAGI].ltime = time(0);
  49.         F_SET(ply_ptr, PRMAGI);
  50.         broadcast_rom(fd, ply_ptr->rom_num, 
  51.             "%M resists magic.", ply_ptr);
  52.         if(how == CAST) {
  53.             print(fd, "You are surrounded by a magical shield.\n");
  54.             ply_ptr->mpcur -= 12;
  55.             ply_ptr->lasttime[LT_RMAGI].interval = MAX(300, 1200 +
  56.                 bonus[ply_ptr->intelligence]*600);
  57. if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  58.             print(fd,"The room's magical properties increase the power of your spell.\n");
  59.             ply_ptr->lasttime[LT_RMAGI].interval += 800L;
  60.         }                                
  61.         }
  62.         else {
  63.             print(fd, "You are surrounded by a magical shield.\n");
  64.             ply_ptr->lasttime[LT_RMAGI].interval = 1200L;
  65.         }
  66.         return(1);
  67.     }
  68.     else {
  69.  
  70.         if(how == POTION) {
  71.             print(fd, "You can only use a potion on yourself.\n");
  72.             return(0);
  73.         }
  74.  
  75.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  76.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply,
  77.                    cmnd->str[2], cmnd->val[2]);
  78.         if(!crt_ptr) {
  79.             print(fd, "I don't see that player here.\n");
  80.             return(0);
  81.         }
  82.  
  83.         F_SET(crt_ptr, PRMAGI);
  84.         crt_ptr->lasttime[LT_RMAGI].ltime = time(0);
  85.         broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num, 
  86.             "%M surrounds %m with a magical shield.",
  87.             ply_ptr, crt_ptr);
  88.         print(crt_ptr->fd, "%M casts resist-magic on you.\n", ply_ptr);
  89.  
  90.         if(how == CAST) {
  91.             print(fd, "You cast a resist-magic spell on %s.\n",
  92.                 crt_ptr);
  93.             ply_ptr->mpcur -= 12;
  94.             crt_ptr->lasttime[LT_RMAGI].interval = MAX(300, 1200 +
  95.                 bonus[ply_ptr->intelligence]*600);
  96. if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  97.             print(fd,"The room's magical properties increase the power of your spell.\n");
  98.             crt_ptr->lasttime[LT_RMAGI].interval += 800L;
  99.         }                                
  100.         }
  101.  
  102.         else {
  103.             print(fd, "%M is surrounded by a magic shield.\n",
  104.                 crt_ptr);
  105.             crt_ptr->lasttime[LT_RMAGI].interval = 1200L;
  106.         }
  107.  
  108.         return(1);
  109.     }
  110.  
  111. }
  112.  
  113. /************************************************************************/
  114. /*                know_alignment                */
  115. /************************************************************************/
  116.  
  117. /* This spell allows the caster to determine what alignment another    */
  118. /* creature or player is by looking at it.                */
  119.  
  120. int know_alignment(ply_ptr, cmnd, how)
  121. creature    *ply_ptr;
  122. cmd        *cmnd;
  123. int        how;
  124. {
  125.     creature    *crt_ptr;
  126.     room        *rom_ptr;
  127.     int        fd;
  128.  
  129.     fd = ply_ptr->fd;
  130.     rom_ptr = ply_ptr->parent_rom;
  131.  
  132.     if(ply_ptr->mpcur < 6 && how == CAST) {
  133.         print(fd, "Not enough magic points.\n");
  134.         return(0);
  135.     }
  136.  
  137.     if(!S_ISSET(ply_ptr, SKNOWA) && how == CAST) {
  138.         print(fd, "You don't know that spell.\n");
  139.         return(0);
  140.     }
  141.  
  142.     if(cmnd->num == 2) {
  143.         ply_ptr->lasttime[LT_KNOWA].ltime = time(0);
  144.         F_SET(ply_ptr, PKNOWA);
  145.         broadcast_rom(fd, ply_ptr->rom_num, 
  146.             "%M casts a know-aura spell.", ply_ptr);
  147.         if(how == CAST) {
  148.             print(fd, "You become more perceptive.\n");
  149.             ply_ptr->mpcur -= 6;
  150.             ply_ptr->lasttime[LT_KNOWA].interval = MAX(300, 1200 +
  151.                 bonus[ply_ptr->intelligence]*600);
  152.         if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  153.                    print(fd,"The room's magical properties increase the power of your spell.\n");
  154.                    ply_ptr->lasttime[LT_KNOWA].interval += 800L;
  155.             }                                
  156.         }
  157.         else {
  158.             print(fd, "You become more perceptive.\n");
  159.             ply_ptr->lasttime[LT_KNOWA].interval = 1200L;
  160.         }
  161.         return(1);
  162.     }
  163.     else {
  164.  
  165.         if(how == POTION) {
  166.             print(fd, "You can only use a potion on yourself.\n");
  167.             return(0);
  168.         }
  169.  
  170.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  171.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply,
  172.                    cmnd->str[2], cmnd->val[2]);
  173.         if(!crt_ptr) {
  174.             print(fd, "I don't see that player here.\n");
  175.             return(0);
  176.         }
  177.  
  178.         F_SET(crt_ptr, PKNOWA);
  179.         crt_ptr->lasttime[LT_KNOWA].ltime = time(0);
  180.         broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num, 
  181.             "%M casts a know-aura spell on %m.",
  182.             ply_ptr, crt_ptr);
  183.         print(crt_ptr->fd, "%M casts know-aura on you.\n",
  184.             ply_ptr);
  185.  
  186.         if(how == CAST) {
  187.             print(fd, "You cast a know-aura spell on %s.\n",
  188.                 crt_ptr);
  189.             ply_ptr->mpcur -= 6;
  190.             crt_ptr->lasttime[LT_KNOWA].interval = MAX(300, 1200 +
  191.                 bonus[ply_ptr->intelligence]*600);
  192.         if (F_ISSET(ply_ptr->parent_rom,RPMEXT)){
  193.                    print(fd,"The room's magical properties increase the power of your spell.\n");
  194.                    crt_ptr->lasttime[LT_KNOWA].interval += 800L;
  195.             }                                
  196.         }
  197.  
  198.         else {
  199.             print(fd, "%M becomes more perceptive.\n",
  200.                 crt_ptr);
  201.             crt_ptr->lasttime[LT_KNOWA].interval = 1200L;
  202.         }
  203.  
  204.         return(1);
  205.     }
  206.  
  207. }
  208.  
  209. /**********************************************************************/
  210. /*            remove-curse                      */
  211. /**********************************************************************/
  212.  
  213. /* This function allows a player to remove a curse on all the items    */
  214. /* in his inventory or on another player's inventory            */
  215.  
  216. int remove_curse(ply_ptr, cmnd, how)
  217. creature    *ply_ptr;
  218. cmd        *cmnd;
  219. int        how;
  220. {
  221.     creature    *crt_ptr;
  222.     room        *rom_ptr, *new_rom;
  223.     int        fd, i;
  224.  
  225.     fd = ply_ptr->fd;
  226.     rom_ptr = ply_ptr->parent_rom;
  227.  
  228.     if(ply_ptr->mpcur < 18 && how == CAST) {
  229.         print(fd, "Not enough magic points.\n");
  230.         return(0);
  231.     }
  232.  
  233.     if(!S_ISSET(ply_ptr, SREMOV) && how == CAST) {
  234.         print(fd, "You don't know that spell.\n");
  235.         return(0);
  236.     }
  237.         if(spell_fail(ply_ptr)) {
  238.                 if(how == CAST)
  239.                      ply_ptr->mpcur -= 18;
  240.                 return(0);
  241.         }
  242.  
  243.  
  244.     /* Cast remove-curse on self */
  245.     if(cmnd->num == 2) {
  246.  
  247.         if(how == CAST)
  248.             ply_ptr->mpcur -= 18;
  249.  
  250.         if(how == CAST || how == SCROLL || how == WAND) {
  251.             print(fd, "Remove-curse spell cast.\n");
  252.             broadcast_rom(fd, ply_ptr->rom_num, 
  253.                       "%M casts remove-curse on %sself.", 
  254.                       ply_ptr,
  255.                       F_ISSET(ply_ptr, PMALES) ? "him":"her");
  256.         }
  257.         else if(how == POTION)
  258.             print(fd, "You feel relieved of burdens.\n");
  259.  
  260.         for(i=0; i<MAXWEAR; i++)
  261.             if(ply_ptr->ready[i])
  262.                 F_CLR(ply_ptr->ready[i], OCURSE);
  263.  
  264.         return(1);
  265.     }
  266.  
  267.     /* Cast remove-curse on another player */
  268.     else {
  269.  
  270.         if(how == POTION) {
  271.             print(fd, "You can only use a potion on yourself.\n");
  272.             return(0);
  273.         }
  274.  
  275.         cmnd->str[2][0] = up(cmnd->str[2][0]);
  276.         crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply,
  277.                    cmnd->str[2], cmnd->val[2]);
  278.  
  279.         if(!crt_ptr) {
  280.             print(fd, "That player is not here.\n");
  281.             return(0);
  282.         }
  283.  
  284.         if(how == CAST)
  285.             ply_ptr->mpcur -= 18;
  286.  
  287.         if(how == CAST || how == SCROLL || how == WAND) {
  288.             print(fd, "Remove-curse cast on %m.\n", crt_ptr);
  289.             print(crt_ptr->fd, 
  290.                   "%M casts a remove-curse spell on you.\n",
  291.                   ply_ptr);
  292.             broadcast_rom2(fd, crt_ptr->fd, ply_ptr->rom_num,
  293.                        "%M casts remove-curse on %m.",
  294.                        ply_ptr, crt_ptr);
  295.  
  296.             for(i=0; i<MAXWEAR; i++)
  297.                 if(crt_ptr->ready[i])
  298.                     F_CLR(crt_ptr->ready[i], OCURSE);
  299.  
  300.             return(1);
  301.         }
  302.     }
  303.  
  304.     return(1);
  305.  
  306. }
  307.